package com.neusoft.mapper;

import java.util.List;
import javax.ws.rs.DELETE;

import org.apache.ibatis.annotations.*;

import com.neusoft.po.Orders;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
	@Options(useGeneratedKeys = true, keyProperty = "orderId", keyColumn = "orderId")
	public int saveOrders(Orders orders);

	public Orders getOrdersById(Integer orderId);
	
	public List<Orders> listOrdersByUserId(String userId);

	@Update("update orders set orderState=1 where orderId=#{orderId}")
	public void updateOrderStateById(Integer orderId);
	@Update("UPDATE orders SET orderState = #{orderState} WHERE orderId = #{orderId}")
	int updateOrder(@Param("orderId") int orderId, @Param("orderState") int orderState);
    public void removeOrder(Integer orderId);
	@Update("UPDATE orders SET comment = #{comment} WHERE orderId = #{orderId}")
	void saveComment(@Param("orderId") Integer orderId, @Param("comment") String comment);

	@Select("SELECT o.comment " +
			"FROM orders o " +
			"WHERE o.businessId = #{businessId} " +
			"AND o.comment IS NOT NULL")
	List<String> getcomment(@Param("businessId") Integer businessId); // 改为返回列表
}
